<template>
	<view class="page-container pb-0 bg-grey">
		<up-navbar safeAreaInsetTop fixed placeholder title="团队列表" :autoBack="true"></up-navbar>
		<zjy-search placeholder="搜索手机号/客户姓名" />
		<scroll-view
			:scroll-y="true"
			@scrolltolower="loadMore"
			:refresher-enabled="true"
			:refresher-triggered="triggered"
			@refresherpulling="onPulling"
			@refresherrefresh="onRefresh"
			@refresherrestore="onRestore"
			@refresherabort="onAbort"
			class="plr-24 pt-24"
			:style="{
				height: scrollViewHeight,
			}"
		>
			<template v-if="listData && listData.length > 0">
				<view v-for="(item, index) in listData" :key="index" class="pb-16">
					<view class="radius-16 bg-white ptb-42 plr-32 flex-a">
						<image
							src="https://oiz.zhijingyou.com/upload/2024/lvapps/1726650540-532718099638976.jpg"
							class="icon-120 radius-16"
							mode="aspectFill"
						/>
						<view class="flex-1 ml-20 mr-24 flex-col space-between h-120">
							<view class="fs-28 font-500">小乖吃喝玩乐记</view>
							<view class="c-grey-86">早睡晚起身体好</view>
							<view class="flex-a">
								<image :src="imgBaseUrl + 'icon-person.png'" class="icon-24" />
								<text class="c-grey-86">11 位达人</text>
							</view>
						</view>
						<zjy-button size="small" pd="0" width="144" @click="navigateTo('/pages/common/res')">
							申请加入
						</zjy-button>
					</view>
				</view>
				<view v-for="(item, index) in listData" :key="index" class="pb-16">
					<view class="radius-16 bg-white ptb-42 plr-32 flex-a">
						<image
							src="https://oiz.zhijingyou.com/upload/2024/lvapps/1726650540-532718099638976.jpg"
							class="icon-120 radius-16"
							mode="aspectFill"
						/>
						<view class="flex-1 ml-20 mr-24 flex-col space-between h-120">
							<view class="fs-28 font-500">小乖吃喝玩乐记</view>
							<view class="c-grey-86">早睡晚起身体好</view>
							<view class="flex-a">
								<image :src="imgBaseUrl + 'icon-person.png'" class="icon-24" />
								<text class="c-grey-86">11 位达人</text>
							</view>
						</view>
						<zjy-button size="small" pd="0" width="144" :disabled="true">已申请</zjy-button>
					</view>
				</view>
			</template>
			<zjy-empty emptyText="暂无订单" v-else-if="!freshing && searched"></zjy-empty>
		</scroll-view>
	</view>
</template>

<script setup lang="ts">
import useCommonStore from "@/store/common"
import { freshLoading } from "@/utils/fresh-loading"
import { navigateTo } from "@/utils/page-redirect"

const imgBaseUrl = inject("imgBaseUrl")
const commonStore = useCommonStore()
const scrollViewHeight = `calc(100vh - ${commonStore.statusBarHeight + commonStore.navbarHeight}px - 88rpx)`
const searched = ref(false)

const search = () => {}

//#region 初始化下拉刷新
const freshLoadingRef = freshLoading()
let {
	loadMore,
	triggered,
	onPulling,
	onRefresh,
	onRestore,
	onAbort,
	getListData,
	listData,
	freshing,
	getListSuccessCallback,
} = freshLoadingRef
freshLoadingRef.listService.value = null
getListSuccessCallback.value = () => {
	searched.value = true
}
freshLoadingRef.listData.value.push(...[1, 2, 1, 1, 1])
//#endregion
</script>
<style lang="scss" scoped></style>
